# 06-图书库存管理系统.py
list = [
    {"id":10086,"name":'ps入门到放弃',"date":'2015-10-01',"price":'99.9',"kc":6},
    {"id":10010,"name":'十大名著',"date":'2024-10-01',"price":'39.9',"kc":5},
    {"id":10000,"name":'重生之我在卖番薯',"date":'2022-10-01',"price":'19.9',"kc":2}
]
# 显示书目信息
def info_book(list):
    for x in list:
        print(x['id'],'\t',x['name'],'\t',x['date'],'\t',x['price'])
# 显示库存信息
def info_kc(list):
    for x in list:
        print(x['id'],'\t',x['name'],'\t',x['kc'])
# 添加图书
def add_book(list):
    id = int(input('请输入书籍编号：'))
    name = input('请输入书籍名称：')
    date = input('请输入书籍出版时间：')
    price = input('请输入书籍价格：')
    list.append({"id":id,"name":name,"date":date,"price":price,"kc":1})
    print('图书添加成功！')
# 修改库存
def update(list):
    id = int(input('请输入书号:'))
    for x in list:
        if x['id']==id:
            kc = int(input('请输入库存量：'))
            x['kc']=kc
        else:
            print('该图书不存在！')
# 主菜单  
def main():
    print("============================================")
    while True:
        print('图书库存管理系统v1.0')
        print('1.显示书目信息')
        print('2.显示图书库存信息')
        print('3.添加书目信息')
        print('4.修改图书库存量')
        print('5.退出系统')
        print('============================================')
        index = input('请输入要执行的操作:')
        if index=="5":break
        if index=="1":info_book(list)
        if index=="3":add_book(list)
main()
